<?php
    @header('Content-type:text/html;charset=utf-8');

    @include_once("conn.php");  // 引入公共的配置文件

    @include_once("noparams.php");

    $user = $_GET["user"];  // 18次

    if(!$user){
        NoParamsErr();
    }

    $sql = "select * from users where user = '$user' ";


    $result = mysqli_query($conn,$sql);
   

    if(!$result){   // $result = false sql语句出现问题  => 阻止脚本的继续向后面允许  
        $obj = array();
        $obj['status'] = false;
        $obj['detail'] = 'Sql语句有问题';
        $obj['sql'] = $sql;
        exit(json_encode($obj));
    }

    $item = mysqli_fetch_assoc($result);
    // print_r($item);

    $obj = array();
    if(!$item){  //没有数据 
        $obj["status"] = true;
        $obj["detail"] = '用户名可以使用!';
    }else{
        $obj["status"] = false;
        $obj["detail"] = '用户名已经被注册!';
    } 

    echo json_encode($obj);

?>
